#ifndef _MAIN_H_
#define _MAIN_H_

#include "gamecore.h"
#include "gamelua.h"
#include "dir.h"
#include "render_card.h"
#include "Canvas.h"
#include "Animation.h"
#include "effect.h"
#include "text.h"
#include "Widget.h"
#include "misc.h"
#include "hash.h"
#include "resource.h"
#include "movement_line.h"
#include "effect_alpha.h"
#include "dirtyrect.h"
#include "actionqueue.h"
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>

//#include <vector>

using namespace animationagent;
//using namespace std;

class GameSpace
{
public:
    GameCore core;
    misc::GHashTable widgethash;
    helper::ResourceManager resourcemanager;
    TTF_Font *font;
    ActionQueue actionqueue;
    Widget layer_background;
    Widget layer_sprite;
    Widget layer_front;
    vector<render_card *> render_cards1;
    vector<render_card *> render_cards2;

    GameSpace();
    ~GameSpace();
    void draw(SDL_Surface *screen);
    void handle_event(SDL_Event *e);
    void handle_user_event(SDL_Event *e);
    void handle_mousemotion(int x, int y);
    void handle_action(ActionNode *node);
    void build_stage();
    void set_render_card(render_card *w, Card *card);

    void play_a_card(GameCore::PlayerID p, int index);

    void do_action();

    void add_action_widget_move(Widget *widget, int type, Uint32 timestamp, Uint32 duration, Sint16 x, Sint16 y);
    void add_action_widget_moveto_abus(Widget *widget, Uint32 timestamp, Uint32 duration, Sint16 x, Sint16 y);
    void add_action_widget_moveto_rela(Widget *widget, Uint32 timestamp, Uint32 duration, Sint16 x, Sint16 y);
    void add_action_widget_putat_abus(Widget *widget, Uint32 timestamp, Uint32 duration, Sint16 x, Sint16 y);
    void add_action_widget_putat_rela(Widget *widget, Uint32 timestamp, Uint32 duration, Sint16 x, Sint16 y);
    void add_action_widget_fade(Widget *widget, int type, Uint32 timestamp, Uint32 duration);
    void add_action_widget_fadein(Widget *widget, Uint32 timestamp, Uint32 duration);
    void add_action_widget_fadeout(Widget *widget, Uint32 timestamp, Uint32 duration);
    void add_action_game(int type, Uint32 timestamp, GameCore::PlayerID p, int index);
};


#endif
